package com.icss.train_sys_back.service.system_service.impl;

import com.icss.train_sys_back.entity.system_manage.RoleEntity;
import com.icss.train_sys_back.mapper.system_manage.RoleManageMapper;
import com.icss.train_sys_back.service.system_service.RoleManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 小泽
 * @createTime 2025/9/29 10:35
 */
@Service
public class RoleManageServiceImpl implements RoleManageService {
    @Autowired
    private RoleManageMapper roleManageMapper;

    //分页+条件查询角色列表
    @Override
    public List<RoleEntity> getListConditions(String roleName, String roleDescription) {
        return roleManageMapper.getListConditions(roleName,roleDescription);
    }

    //添加角色
    @Override
    public boolean add(RoleEntity role) {
        return roleManageMapper.add(role);
    }

    //删除角色
    @Override
    public boolean delete(Integer roleId) {
        return roleManageMapper.delete(roleId);
    }

    //更新角色
    @Override
    public boolean update(RoleEntity role) {
        return roleManageMapper.update(role);
    }

    //根据角色Id删除原有的权限
    @Override
    public boolean deletePermissionsByRoleId(Integer roleId) {
        return roleManageMapper.deletePermissionsByRoleId(roleId);
    }

    //根据角色Id保存对应的权限
    @Override
    public void insertRolePermissions(Integer roleId, List<Integer> permissionIds) {
        roleManageMapper.insertRolePermissions(roleId,permissionIds);
    }

    //根据角色Id获取角色对应的权限Ids
    @Override
    public List<Integer> getRolePermissions(Integer roleId) {
        return roleManageMapper.getRolePermissions(roleId);
    }
    //获取系统中所有角色的列表，为用户管理页面中的角色选择下拉框提供数据
    @Override
    public List<RoleEntity> getAllRoles() {
        return roleManageMapper.getAllRoles();
    }
}
